﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConciseMarkupLanguage.Filters
{
    public static class Django
    {
        /// <summary>
        /// Adds the argument to the value.
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        [Filter]
        public static int add(int a, int b)
        {
            return a + b;
        }

        /// <summary>
        /// Capitalizes the first character of the value.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        [Filter]
        public static string capfirst(string s)
        {
            return char.ToUpper(s[0]) + s.Substring(1);
        }

        /// <summary>
        /// Formats a date according to the given format.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        /// <see cref="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx"/>
        /// <see cref="http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx"/>
        [Filter]
        public static string date(DateTime dt, string format)
        {
            return dt.ToString(format);
        }
    }
}
